package isquirrel.beans;

import static org.junit.Assert.*;

import org.junit.Test;


public class PropertyTest {
	
	@Test
	public void testEquals() {
		Property p1 = new Property("skos:subject","dbpedia:Bird");
		p1.setFrequency(1);
		Property p2 = new Property("skos:subject","dbpedia:Person");
		p2.setFrequency(2);
		Property p3 = new Property("skos:subject","dbpedia:Bird");
		p3.setFrequency(3);
		Property p4 = new Property("skos:game","dbpedia:Bird");
		p3.setFrequency(4);
		
		assertTrue(p1.hashCode() == p3.hashCode());
		assertFalse(p1.hashCode() == p2.hashCode());
		assertFalse(p1.hashCode() == p4.hashCode());
		
		assertTrue(p1.equals(p3));
		assertFalse(p1.equals(p2));
		assertFalse(p1.equals(p4));
		assertFalse(p2.equals(p3));
		assertFalse(p2.equals(p4));
		assertFalse(p3.equals(p4));
		
	}
	
	@Test
	public void testCompareTo() {
		Property p1 = new Property("skos:subject","dbpedia:Bird");
		p1.setFrequency(1);
		Property p2 = new Property("skos:subject","dbpedia:Person");
		p2.setFrequency(2);
		Property p3 = new Property("skos:subject","dbpedia:Bird");
		p3.setFrequency(3);
		Property p4 = new Property("skos:game","dbpedia:Bird");
		p3.setFrequency(4);
		
		assertTrue(p1.compareTo(p2) < 0);
		assertTrue(p1.compareTo(p3) == 0);
		assertTrue(p1.compareTo(p4) > 0);
	}

}
